<?php
class ApiCenter_ProductApi_Model_Api2_Product_Setcategory_Rest_Admin_V1 extends  ApiCenter_ProductApi_Model_Api2_Product_Setcategory_Rest{
    
    protected function _retrieve(){

            $categoryId = $this->getRequest()->getParam("categoryid");
            $resData = $this->_queryAllCategory($categoryId);
            $res['status']=1;
            $res['info']=$resData;

        return $res;
    }
    protected function _retrieveCollection(){
            $childItem=array();
            $resData = $this->_queryAllCategory(2);
            foreach ($resData as $k => $v){
                $childItem[$k]['id'] = $v['entity_id'];
                $childItem[$k]['parentid'] = $v['parent_id'];
                $childItem[$k]['text'] = $v['text'];
                if($v['children_count'] == "0"){   
                    $childItem[$k]['set_id']=$this->_loadSetIdFromcategroy($v['entity_id']);  
                }
            }
            $res['status']=1;
            $res['info']=$childItem;

        return $res;
    }
    protected  function _loadSetIdFromcategroy($categoryId){
        $set = Mage::getModel('attrbindcategory/set')->load($categoryId,"category_id");
        	
       return !empty($set->getAttributesetId())?$set->getAttributesetId():0;
    }
}